home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
text
/
print
/
GraphPaper_src.lha
/
MathPaperPrint2.S
Wrap
Text File
|
1997-09-23
|
49KB
|
2,511 lines
**********
********** Printroutine voor verschillende types papier
**********
********** door Maurice van Wanum © 1996/1997
**********
incdir ASM-One:
incdir Include2.0:
* standaard macros *
include Macros.S
* exec *
include exec/exec_lib.i
include exec/types.i
include exec/memory.i
include exec/ports.i
include devices/printer.i
include devices/prtbase.i
* dos *
include libraries/dos_lib.i
include libraries/dos.i
* graphics *
include graphics/graphics_lib.i
include graphics/gfx.i
include graphics/rastport.i
* intuition *
include intuition/intuition.i
include intuition/intuition_lib.i
* gadtools *
include libraries/gadtools.i
include libraries/gadtools_lib.i
* workbench *
include workbench/workbench.i
include workbench/startup.i
include workbench/icon_lib.i
Fix =-30 ; offsets van de Mathffp.lib
Flt =-36
Neg =-60
Add =-66
Sub =-72
Mul =-78
Div =-84
_LVOFix =-30 ; offsets van de Mathffp.lib
_LVOFlt =-36
_LVOCmp =-42
_LVONeg =-60
_LVOAdd =-66
_LVOSub =-72
_LVOMul =-78
_LVODiv =-84
Macht =-90 ; offsets van de mathtrans.lib
Log10 =-126
LogPapier equ 1
AntiLogPapier equ 2
LincmPapier equ 3
LinhalfPapier equ 4
LinmmPapier equ 5
half equ $80000040
cmpinch equ $c993263f
tiende equ $cccccd3d
WFLAG SET ACTIVATE!WINDOWDRAG!WINDOWDEPTH!WINDOWCLOSE
WFLAG SET WFLAG!SIMPLE_REFRESH!WFLG_RMBTRAP
; Use lowest non-obsolete version that supplies the functions you need.
INTUITION_REV equ 37
NULL equ 0
lib MACRO
Lib \1
ENDM
save = 0
debug = 0 extra info
Startup move.l 4.w,a6
if save
AUTO WO\
sub.l a1,a1
Lib FindTask ; onze task zoeken
move.l d0,a2
tst.l $ac(a2)
bne.W CLIStart ; geen 0 -> vanuit CLI (of Shell)
; Workbench-Startup
lea $5c(a2),a0
Lib WaitPort
lea $5c(a2),a0
Lib GetMsg
push.l d0
bsr.s GetPrefs
bsr.w CLIStart
pop.l a1
move.l 4.w,a6
LibJ ReplyMsg reply-message
GetPrefs
OpenLib iconnaam
tst.l d0
beq.b .noiconlib helaas geen icon.lib ??
move.l d0,a5
OpenLib dosnaam
move.l d0,a6
move.l 4(SP),a2 WB-Message
move.l sm_NumArgs(a2),d2 aantal argumenten
subq.l #1,d2
bcs.b .noargs
move.l sm_ArgList(a2),a2
.nexticon
move.l (a2)+,d1
Lib CurrentDir pas dir aan
move.l (a2)+,a0
exg a5,a6
Lib GetDiskObject haal icon
tst.l d0
beq.s .noicon -> geen icon
push.l d0
move.l d0,a0
move.l do_ToolTypes(a0),a3 a3 = tooltype-array
bsr.s GetToolTypes zoek tooltypes uit
pop.l a0
Lib FreeDiskObject geef icon weer vrij
.noicon
exg a5,a6
dbf d2,.nexticon
.noargs
move.l a6,a1
move.l 4.w,a6
Lib CloseLibrary
move.l a5,a1
Lib CloseLibrary
.noiconlib
rts
****** in : a3 = tooltype-array
GetToolTypes
push.l a2
*** doe windowposities
lea newwin(PC),a2
lea _MAINPOS(PC),a4
bsr.w GetWinPos hoofdwindow
lea InstelWin(PC),a2
bsr.w GetWinPos instelwindow
lea AbortWin(PC),a2
bsr.w GetWinPos afbreekwindow
*** doe eenheden
lea _EENH(PC),a1
moveq #'X',d0
bsr.w FindTool x eenheden
beq.s .yeenh
move.l d0,a0
bsr.w Getnum
move.l d0,xEenheden
.yeenh lea _EENH(PC),a1
moveq #'Y',d0
bsr.w FindTool y eenheden
beq.s .donums
move.l d0,a0
bsr.w Getnum
move.l d0,yEenheden
*** doe de X-waardes
** numerieke waardes
.donums move.l a3,a0
lea xPrimdkt(PC),a2
moveq #'X',d3
bsr.w ZoekDiktes zoek prim, sec en tert diktes
lea _LOGBRD(PC),a1
move.l a3,a0
Lib FindToolType decade-breedte
tst.l d0
beq.s .xpaper
move.l d0,a0
bsr.w Getnum
move.l d0,xDecbrd
** papiertype
.xpaper lea _PAPER(PC),A1
moveq #'X',d0
bsr.b FindTool papier X
beq.s .yprefs
bsr.w GetIconPaper
tst d4
bmi.s .yprefs
addq #1,d4
move.b d4,xType zet type papier
*** doe y-waardes
** numerieke waardes
.yprefs move.l a3,a0
lea yPrimdkt(PC),a2
moveq #'Y',d3
bsr.w ZoekDiktes zoek prim, sec en tert diktes
lea _LOGHGT(PC),a1
move.l a3,a0
Lib FindToolType decade-hoogte
tst.l d0
beq.s .ypaper
move.l d0,a0
bsr.w Getnum
move.l d0,yDecbrd
** papier-type
.ypaper lea _PAPER(PC),A1
moveq #'Y',d0
bsr.b FindTool papier Y
beq.b .exit
bsr.b GetIconPaper
tst.w d4
bmi.b .exit
addq #1,d4
move.b d4,yType zet type papier
*** klaar
.exit pop.l a2
rts
*** in : a0 = string
*** d0 = 'X' of 'Y'
ZetXY tst.b (a0)+
bne.s ZetXY
.1 cmp.b #'_',-(a0)
bne.s .1
move.b d0,1(a0)
rts
**** in : a1 = string
**** a3 = tooltypearray
**** d0 = 'X' of 'Y'
**** uit : d0 = pointer naar tooltype
**** a0 = d0
**** SR = tst.l d0
FindTool
move.l a1,a0
bsr.s ZetXY
move.l a3,a0
Lib FindToolType
move.l d0,a0
tst.l d0
rts
***** Zoek de positie van het window uit
***** in : a4 = naam van x/y positie
***** a3 = tooltypearray
***** a2 = pointer naar newwindow-struct
***** uit : a4 = volgende naam
GetWinPos
move.l a4,a1
moveq #'X',d0
bsr.b FindTool
beq.s .ypos
bsr.b Getnum
move d0,(a2)+
.ypos move.l a4,a1
moveq #'Y',d0
bsr.b FindTool
beq.s .ex
bsr.b Getnum
move d0,(a2)+
.ex tst.b (a4)+
bne.s .ex
rts
****** in : d0=tooltype
****** uit: d4=gadno
GetIconPaper
move.l d0,a2
lea typetab(PC),a4
moveq #4,d4
.lus move (a4)+,d0
lea -2(a4,d0.w),a1
move.l a2,a0
Lib MatchToolValue
tst.l d0
bne.s .found
move (a4)+,d0
lea -2(a4,d0.w),a1
move.l a2,a0
Lib MatchToolValue
tst.l d0
dbNe d4,.lus
.found rts
typetab Dr.w _MM,_MM2
Dr.w _HALCM,_HALCM2
Dr.w _CM,_CM2
Dr.w _ALOG,_ALOG2
dr.w _LOG,_LOG2
***** scratch : a0/a1/a2/a4/d0/d1/d4
***** in : d3 = 'X' of 'Y'
***** a2 = PrefsUit
***** a3 = ToolTypeArray
***** uit: --
ZoekDiktes
moveq #2,d4
lea tooltab(PC),a4
.lus move (a4)+,d0
lea -2(a4,d0.w),a1
move d3,d0
bsr.b FindTool
beq.s .next niet gevonden
bsr.b Getnum
move.l d0,(a2)
.next addq #4,a2
dbf d4,.lus
rts
tooltab dr.w _PRIM
dr.w _SEC
dr.w _TER
**** scratch : d0/d1/a0
**** in : a0 = string
**** uit: d0 = getal
Getnum moveq #0,d0
.space move.b (a0)+,d1
cmp.b #' ',d1 sla spaties over
beq.s .space
.next cmp.b #'9',d1
bhi.s .nonum
cmp.b #'0',d1
blo.s .nonum
and.w #$f,d1
mulu #10,d0
add.w d1,d0
move.b (a0)+,d1
bra.s .next
.nonum rts
**** window-posities is nog te doen
_MAINPOS DC.B 'WINDOW_XPOS',0
_INSTELPOS DC.B 'INSTELWINDOW_XPOS',0
_PRINTPOS DC.B 'PRINTWINDOW_XPOS',0
**** algemene printopties
_PRIM dc.b 'PRIMAIRE_DIKTE_X',0
_SEC dc.b 'SECUNDAIRE_DIKTE_X',0
_TER dc.b 'TERTIAIRE_DIKTE_X',0
_PAPER dc.b 'PAPIERSOORT_X',0
_LOG dc.b 'LOGARITMISCH',0
_LOG2 DC.B 'LOG',0
_ALOG DC.B 'ANTI_LOGARITMISCH',0
_ALOG2 DC.B 'ALOG',0
_CM DC.B 'CENTIMETER',0
_CM2 DC.B 'CM',0
_MM DC.B 'MILLIMETER',0
_MM2 DC.B 'MM',0
_HALCM DC.B 'HALVE_CENTIMETER',0
_HALCM2 DC.B '½CM',0
_LOGBRD dc.b 'LOG_BREEDTE',0
_LOGHGT dc.b 'LOG_HOOGTE',0
_EENH dc.b 'EENHEDEN_X',0
even
CLIStart
endif
move.l #datasize,d0
move.l #MEMF_CLEAR,d1
Lib AllocMem geheugen voor variabelen
move.l d0,a4
tst.l d0
beq.w nomem
OpenLib dosnaam open dos.lib
move.l d0,DosBase(a4)
OpenLib intuition,INTUITION_REV
move.l d0,intbase(a4) open int.lib
beq.w noint
OpenLib graphics
move.l d0,gfxbase(a4) open gfx.lib
beq.w nogfx
retrygadlib
OpenLib gadnaam
move.l d0,gadbase(a4)
beq.b NoGTlib
if debug
lea ConName(PC),a0
move.l a0,d1
move.l #MODE_OLDFILE,d2
move.l DosBase(a4),a6
Lib Open
move.l d0,ConHD
beq NoCon
endif
RetryMathTR
move.l 4.w,a6
lea MathTRName(PC),a1
Lib OldOpenLibrary
move.l d0,MathTR(a4)
beq.b NoMathTR
RetryMath
lea MathName(PC),a1
Lib OldOpenLibrary
move.l d0,a6
move.l d0,Math(a4)
beq.b NoMath
push.l a4
bsr.w main
pop.l a4
bra.b Einde
;====== foutroutines en afsluiten
NoMath
if debug
lea _NoMath(PC),a0
bsr print
bra NoMathClose
else
lea MathName(PC),a0
lea RetryMath(PC),a1
lea NoMathClose(PC),a2
bra.b AutoReq
endif
NoMathTR
if debug
lea _NoMathTR(PC),a0
bsr print
bra NoMathTRClose
else
lea MathTRName(PC),a0
lea RetryMathTR(PC),a1
lea NoMathTRClose(PC),a2
bra.b AutoReq
endif
NoGTlib lea gadnaam(PC),a0
lea retrygadlib(PC),a1
lea nogadtools(PC),a2
bra.b AutoReq
******* afsluiten van programma's
Einde move.l Math(a4),a1 sluit mathffp.lib
move.l 4.w,a6
Lib CloseLibrary
NoMathClose
move.l MathTR(a4),a1 sluit mathtrans.lib
move.l 4.w,a6
Lib CloseLibrary
NoMathTRClose
if debug
lea _TVV(PC),a0
bsr print 'toets voor verder'
move.l ConHD(PC),d1
lea _Buff(PC),a0
move.l a0,d2
moveq #1,d3
move.l DosBase(a4),a6
lib Read lees een toets
move.l ConHD(PC),d1 sluit con-window
Lib Close
endif
NoCon
libclose
move.l 4.w,a6
move.l gadbase(a4),a1
Lib CloseLibrary sluit gadtools.lib
nogadtools
move.l gfxbase(a4),a1
Lib CloseLibrary sluit gfx.lib
nogfx
move.l intbase(a4),a1
Lib CloseLibrary sluit int.lib
noint move.l DosBase(a4),a1
Lib CloseLibrary sluit dos.lib
move.l a4,a1
move.l #datasize,d0
Lib FreeMem geef geheugen terug
moveq #0,d0 ok-waarde
rts
nomem moveq #103,d0 foutwaarde : te weinig geheugen
rts
***** Een routine die een Easyrequester-gebruikt
***** in :
***** a0 = BodyTekst
***** a1 = RetryCode
***** a2 = CancelCode
***** uit : sprong naar routine a1 of a2
AutoReq
movem.l a1/a2/a3/a6,-(SP)
push.l a0 args
move.l SP,a3
pea .gadg(PC)
pea .body(PC)
clr.l -(SP) titel
clr.l -(SP) flags
pea [es_SIZEOF].w
move.l WindowHD(a4),a0
move.l sp,a1
sub.l a2,a2
move.l intbase(a4),a6
Lib EasyRequestArgs
lea es_SIZEOF+4(SP),SP
movem.l (SP)+,a1/a2/a3/a6
tst.l d0
bne.s .yes
jmp (a2) doe CancelCode
.yes jmp (a1) doe RetryCode
.body dc.b "Can't open %s !",0
.gadg dc.b 'Opnieuw|Afbreken',0
even
** open window met visualinfo/context
** in : a0 = newwindow
** uit: d0 = succes
opengtwin
move.l intbase(a4),a6
Lib OpenWindow
move.l d0,WindowHD(a4)
beq.b .err
move.l d0,a0
move.l wd_WScreen(a0),a0
sub.l a1,a1
move.l gadbase(a4),a6
Lib GetVisualInfoA
move.l d0,vis_info(a4)
beq.w novisinfo
lea gadlist(a4),a0
Lib CreateContext
move.l d0,gadcont(a4)
beq.w nocontext
.err rts
****
**** vraag instellingen van papier
****
GetType lea newwin(PC),a0
bsr.b opengtwin
tst.l d0
beq.w NoWin
bsr.w MaakGetTypeGadgets
tst.l d0
beq.w nogadgets
* gadgets toevoegen aan window *
bsr.w addgtgads
** wachtlus
gt_lus move.l WindowHD(a4),a0
move.l 86(a0),a0
move.l 4.w,a6
Lib WaitPort
move.l WindowHD(a4),a0
move.l 86(a0),a0
move.l gadbase(a4),a6
Lib GT_GetIMsg
move.l d0,a1
move.l im_Class(a1),d3 IDCMP-code
move im_Code(a1),d2 special-data
move.l im_IAddress(a1),a2 gadgetptr
Lib GT_ReplyIMsg
cmp.l #IDCMP_CLOSEWINDOW,d3 sluit symbool ??
beq.w gt_Cancel
cmp.l #IDCMP_GADGETUP,D3
beq.b gt_Gadget
cmp.l #IDCMP_GADGETDOWN,D3
BEQ.B gt_Gadget
cmp.l #IDCMP_REFRESHWINDOW,d3
beq.b .refrwin
bra.b gt_lus
.refrwin
move.l WindowHD(a4),a0
Lib GT_BeginRefresh
move.l WindowHD(a4),a0
moveq #1,d0
Lib GT_EndRefresh
bra.b gt_lus
gt_Gadget
move gg_GadgetID(a2),d0 nummer
cmp #xPapID,d0
beq.b gt_xpap
cmp #yPapID,d0
beq.b gt_ypap
cmp #xEenhID,d0
beq.b gt_xEenh
cmp #yEenhID,d0
beq.b gt_yEenh
cmp #CancID,d0
beq.b gt_Cancel sluiten
cmp #OkID,d0
beq.b gt_Ok sluiten & printen
cmp #xInstID,d0
beq.w gt_xInstellingen xPrefs
cmp #yInstID,d0
beq.w gt_yInstellingen yPrefs
bra.w gt_lus
gt_xpap addq #1,d2
move.b d2,xType
bra.w gt_lus
gt_ypap addq #1,d2
move.b d2,yType
bra.w gt_lus
gt_xEenh
move.l gg_SpecialInfo(a2),a0
move.l si_LongInt(a0),xEenheden
bra.w gt_lus
gt_yEenh
move.l gg_SpecialInfo(a2),a0
move.l si_LongInt(a0),yEenheden
bra.w gt_lus
gt_Cancel
bsr.b ClosegtWin
moveq #0,d0 niet printen
rts
gt_Ok bsr.b ClosegtWin
moveq #1,d0 wel printen
rts
ClosegtWin
move.l WindowHD(a4),a0
move.l 4(a0),newwin
CloseWin * Sluit window, libs, etc. *
move.l WindowHD(a4),a0
move.l gadlist(a4),a1
moveq #-1,d0 alle gadgets
move.l intbase(a4),A6
Lib RemoveGList eerst gadgets uitzetten
nogadgets
move.l gadbase(a4),a6
move.l gadlist(a4),a0
Lib FreeGadgets geef daarna gadgets vrij
nocontext
move.l gadbase(a4),a6
move.l vis_info(a4),a0
Lib FreeVisualInfo
novisinfo * sluit window *
move.l WindowHD(a4),a0
move.l intbase(a4),a6
Lib CloseWindow
moveq #0,d0 foutcode
rts
NoWin lea _window(PC),a0
lea GetType(PC),a1
lea .nowin(PC),a2
bra.w AutoReq
.nowin moveq #0,d0 niet printen
rts
gt_xInstellingen
lea xDecbrd(pc),a2
bsr.b ZetInstellingen
lea xWinNaam(PC),a0
bsr.w Instellingen
tst d0
bne.s .err Cancel-gekozen
lea xDecbrd(pc),a2
bsr.b ZoekInstellingen
.err bra.w GetType
gt_yInstellingen
lea yDecbrd(pc),a2
bsr.b ZetInstellingen
lea yWinNaam(PC),a0
bsr.b Instellingen
tst d0
bne.s .err Cancel-gekozen
lea yDecbrd(pc),a2
bsr.b ZoekInstellingen
.err bra.w GetType
ZetInstellingen
lea .tab2(PC),a1
moveq #3,d2
.1 move (a1)+,d1
move.l (a2)+,-2(a1,d1.w)
dbf d2,.1
rts
.tab2 dr.w Decades
dr.w Primdkt
dr.w Secdkt
dr.w Terdkt
ZoekInstellingen
lea .tab(PC),a0
moveq #3,d0
.1 move.w (a0)+,d1
move.l -2(a0,d1.w),(a2)+
dbf d0,.1
rts
.tab dr.w Decades
dr.w Primdkt
dr.w Secdkt
dr.w Terdkt
if debug
pdec ext.l d0
movem.l d2/a2/a3,-(SP)
lea .buffer(PC),a3
bsr PrintInt
movem.l (SP)+,d2/a2/a3
lea .buffer(PC),a0
bra print
.buffer dcb.b 8,0
;====== Function that will use the string '%ld' and makes an output
;====== in OutBuff (a3) in C-style
PrintInt
move.l 4.w,a6
lea _ld(PC),a0 our input-string
push.l d0
move.l SP,a1 our Arguments
lea Function(PC),a2 ; our store-function; this one could be used
; to maintain a buffer and print it when it is
; full. However our function just copies.
; lea OutBuff(PC),a3 a3 = our outbuff
Lib RawDoFmt
addq.l #4,SP
rts ; End of our program
;=== in : d0=byte to be printed
;=== a3=buffer
;=== out : a3=a3+1
Function
move.b d0,(a3)+
rts
endif
addgtgads * voeg gt-gadgets toe aan window *
move.l WindowHD(a4),a0
move.l gadlist(a4),a1 gadgets
moveq #-1,d0 positie (achteraan)
moveq #-1,d1 #gadgets (alle)
sub.l a2,a2
move.l intbase(a4),a6
Lib AddGList
move.l gadlist(a4),a0
MOVE.L WindowHD(a4),a1
sub.l a2,a2
moveq #-1,d0 alle gadgets
Lib RefreshGList
move.l gadbase(a4),a6
move.l WindowHD(a4),a0
sub.l a1,a1
LibJ GT_RefreshWindow
Instellingen
move.l a0,InstelWin+nw_Title
move.l WindowHD(a4),a0
move.l 4(a0),newwin
bsr.w CloseWin sluit en ruim op
move.l intbase(a4),a6
lea InstelWin(PC),a0
bsr.w opengtwin
tst.l d0
beq.w .nowin
bsr.w MaakInstGadgets
tst.l d0
beq.w nogadgets
* gadgets toevoegen aan window *
bsr.b addgtgads
* verwerk boodschappen *
.1 move.l WindowHD(a4),a0
move.l wd_UserPort(a0),a0
move.l 4.w,a6
Lib WaitPort
move.l WindowHD(a4),a0
move.l wd_UserPort(a0),a0
move.l gadbase(a4),a6
Lib GT_GetIMsg
move.l d0,a1
move.l 20(a1),d0
cmp.l #IDCMP_CLOSEWINDOW,d0 sluit symbool ??
beq.b .Cancel
cmp.l #IDCMP_GADGETUP,d0
beq.b .Gadget handel gadget af
cmp.l #IDCMP_REFRESHWINDOW,D0
beq.b .refr
Lib GT_ReplyIMsg
bra.b .1
.refr Lib GT_ReplyIMsg
move.l WindowHD(a4),a0
Lib GT_BeginRefresh
move.l WindowHD(a4),a0
moveq #1,d0
Lib GT_EndRefresh
bra.b .1
.Gadget move.l 28(a1),a2 gadget naar a2
Lib GT_ReplyIMsg
move gg_GadgetID(a2),d0 nummer
beq.b .num getal ingetikt
cmp #OkID,d0
beq.s .ok
cmp #CancID,d0
beq.s .Cancel
bra.b .1
.num move.l gg_UserData(a2),a0
move.l gg_SpecialInfo(a2),a1
move.l si_LongInt(a1),(a0)
bra.w .1
.ok move.l WindowHD(a4),a0
move.l 4(a0),InstelWin
bsr.w CloseWin
moveq #0,d0
rts
.Cancel move.l WindowHD(a4),a0
move.l 4(a0),InstelWin
bra.w CloseWin
.nowin
lea _window(PC),a0
lea Instellingen(PC),a1
lea .canwin(PC),a2
bra.w AutoReq
.canwin
moveq #-1,d0 fout
rts
if debug
;======= print string
print move.l a0,d2
.1 tst.b (a0)+
bne.s .1
move.l a0,d3
sub.l d2,d3
subq #1,d3
move.l ConHD(PC),d1
move.l DosBase(a4),a6
LibJ Write
;=======
;======= Printroutine
;=======
PFLT movem.l d1-d6/a6,-(SP)
move.l d0,d4
btst #7,d0
beq .2
lea _Min(PC),a0
bsr print
bclr #7,d4
.2 move.l d4,d0
move.l MathTR(a4),a6
jsr Log10(a6) ; 10 log nemen voor de exponent
move.l Math(a4),a6
btst #7,d0
beq .6
move.l #$800000c1,d1
jsr Add(a6)
.6 jsr Fix(a6)
.exppl move.b d0,EXP
neg.l d0
addq.l #4,d0
jsr Flt(A6)
move.l d0,d2
moveq #10,d0
jsr Flt(A6)
move.l MathTR(a4),a6
move.l d2,d1
jsr Macht(A6) ; vermenigvuldigen voor omzetten
move.l Math(a4),a6
move.l d4,d1
jsr Mul(a6)
move.l #$80000040,d1
jsr Add(A6)
jsr Fix(a6) ; omzetten in een integer
move.l d0,d1
moveq #3,d0
lea _dec+6(PC),a0 ; print fractie
.1 divu #10,d1
swap d1
or.b #$30,d1
move.b d1,-(a0)
clr.w d1
swap d1
dbf d0,.1
cmp.w #10,d1
bmi .nerr
moveq #0,d0
move.b EXP(PC),d0
addq #1,d0
bra .exppl
.nerr subq #2,a0
move.b d1,(a0)
or.w #'0.',(a0)
lea _dec+6(PC),a1
.5 cmp.b #$30,-(a1)
beq .5
clr.b 1(A1)
cmp.b #'.',(a1)
bne .4
clr.b (a1)
.4 bsr print ; print Exponent
move.b EXP(PC),d0
beq .noexp
lea _SHSH(PC),a0
bsr print
moveq #0,d0
move.b EXP(PC),d0
bpl .3
lea _Min(PC),a0
bsr print
moveq #0,d0
sub.b EXP(PC),d0
.3 divu #10,d0
lea _dec+4(PC),a0
move.b d0,(a0)
swap d0
move.b d0,1(A0)
or.w #$3030,(A0)
bsr print
.noexp lea _LF(PC),a0 ; volgende regel
bsr print
movem.l (SP)+,d1-d6/a6
rts
endif
InstelWin
DC.W 120,25 X,Y
DC.W 300,100 Breedte,Hoogte.
DC.B 0 Letterkleur 0.
DC.B 1 Achtergrondkleur 1.
DC.L IDCMP_CLOSEWINDOW!IDCMP_REFRESHWINDOW!BUTTONIDCMP
DC.L WFLAG Window-mogelijkheden.
DC.L 0 Gadgets.
DC.L 0 Grafisch.
DC.L 0 Adres van de titel van het window.
DC.L 0 Adres van het screen (0=WorkBench).(30)
DC.L 0 Adres van de bitmap (geen). (34)
DC.W 0,0 Breedte/Hoogte minimaal.
DC.W 0,0 Breedte/Hoogte maximaal.
DC.W 1 Scherm-type : 1=WorkBench, 15=custom
PrefOffs equ 168
Decades dc.l 0
Primdkt dc.l 0
Secdkt dc.l 0
Terdkt dc.l 0
***
*** Maak Gadgets
***
MaakInstGadgets
* gadget 1 : integer-gadget: decades *
lea in_newgad(PC),a1
move.l vis_info(a4),gng_VisualInfo(a1)
move #15,gng_TopEdge(a1)
move #PrefOffs,gng_LeftEdge(a1)
move #48,gng_Width(a1)
clr gng_GadgetID(a1)
moveq #PLACETEXT_LEFT,d0
move.l d0,gng_Flags(a1)
lea _decade(PC),a0
lea Decades(PC),a2
bsr.w in_intgadsh
beq.w in_nogadgets
* gadget 2 : integer-gadget: primair *
lea _prim(PC),a0
lea Primdkt(PC),a2
bsr.w in_intgad
beq.w in_nogadgets
* gadget 3 : integer-gadget: secundair *
lea _sec(PC),a0
lea Secdkt(PC),a2
bsr.w in_intgad
beq.w in_nogadgets
* gadget 4 : integer-gadget: tertair *
lea _ter(PC),a0
lea Terdkt(pc),a2
bsr.w in_intgad
beq.w in_nogadgets
* gadget 5 : button : Goed *
lea in_newgad(PC),a1
add #hgt+INTERHEIGHT,gng_TopEdge(a1)
move #xOffs,gng_LeftEdge(a1)
move #150-2*xOffs,gng_Width(a1)
move #OkID,gng_GadgetID(a1)
lea _goed(PC),a0
move.l a0,gng_GadgetText(a1)
moveq #PLACETEXT_IN,d0
move.l d0,gng_Flags(a1)
move.l gadcont(a4),a0
moveq #BUTTON_KIND,d0
sub.l a2,a2 taglist
Lib CreateGadgetA
move.l d0,gadcont(a4)
beq.w in_nogadgets
* gadget 6 : button : Cancel *
lea in_newgad(PC),a1
move #150+xOffs,gng_LeftEdge(a1)
move #CancID,gng_GadgetID(a1)
lea _cancel(PC),a0
move.l a0,gng_GadgetText(a1)
move.l gadcont(a4),a0
moveq #BUTTON_KIND,d0
sub.l a2,a2 taglist
Lib CreateGadgetA
move.l d0,gadcont(a4)
beq.b in_nogadgets
* gadget 7 : Text-gadget : mm *
lea in_newgad(pc),a1
move #PrefOffs+48,gng_LeftEdge(a1)
move #15,gng_TopEdge(a1)
clr gng_Width(a1)
lea _mm(PC),a0
move.l a0,gng_GadgetText(a1)
moveq #PLACETEXT_RIGHT,d0
move.l d0,gng_Flags(a1)
move.l gadcont(a4),a0
moveq #TEXT_KIND,d0
sub.l a2,a2
Lib CreateGadgetA
move.l d0,gadcont(a4)
beq.b in_nogadgets
* gadget 8,9,10 : Text-gadget : prim/sec/ter-pixels *
moveq #3-1,d2
.1 lea in_newgad(pc),a1
add #hgt+INTERHEIGHT,gng_TopEdge(a1)
lea _pixels(PC),a0
move.l a0,gng_GadgetText(a1)
move.l gadcont(a4),a0
moveq #TEXT_KIND,d0
sub.l a2,a2
Lib CreateGadgetA
move.l d0,gadcont(a4)
dbeq d2,.1
in_nogadgets
rts
* integergadget, volgende regel, 4 letters/max
* in : a0 = tekst
* a2 = variabele
in_intgad
lea in_newgad(PC),a1
add #hgt+INTERHEIGHT,gng_TopEdge(a1)
in_intgadsh * speciaal voor decades *
move.l a0,gng_GadgetText(a1)
move.l a2,gng_UserData(a1)
clr.l -(sp) tag_end
pea 4.w
push.l #GTIN_MaxChars
push.l (a2)
push.l #GTIN_Number
move.l SP,a2 taglist
move.l gadcont(a4),a0
moveq #INTEGER_KIND,d0
Lib CreateGadgetA
lea 5*4(SP),sp
move.l d0,gadcont(a4)
rts
** newgadget **
in_newgad
dc.w 0,0 x/y
dc.w brd,hgt brd/hgt
dc.l 0 text
dc.l topaz8 textattr
dc.w 0 ID
dc.l 0 flags
dc.l 0 vis_info
dc.l 0 userdata
AbortX equ 156
AbortY equ 30
AbortWin
DC.W 120,25 X,Y
DC.W AbortX+20,AbortY+22 Breedte,Hoogte.
DC.B 0,1 Letterkleur/Achtergrondkleur 0/1.
DC.L CLOSEWINDOW!BUTTONIDCMP!IDCMP_REFRESHWINDOW
DC.L WFLAG Window-mogelijkheden.
DC.L 0 Gadgets.
DC.L 0 Grafisch.
DC.L WindowTitel Adres van de titel van het window.
DC.L 0 Adres van het screen (0=WorkBench).(30)
DC.L 0 Adres van de bitmap (geen). (34)
DC.W 0,0 Breedte/Hoogte minimaal.
DC.W 0,0 Breedte/Hoogte maximaal.
DC.W 1 Scherm-type : 1=WorkBench, 15=custom
topaz8 dc.l topaznaam
dc.w 8,0
topaz9 dc.l topaznaam
dc.w 9,0
newwin DC.W 120,25 X,Y
DC.W 350,129 Breedte,Hoogte.
DC.B 0,1 Letterkleur 0/Achtergrondkleur 1.
DC.L CLOSEWINDOW!BUTTONIDCMP!MXIDCMP!IDCMP_REFRESHWINDOW
DC.L WFLAG Window-mogelijkheden.
DC.L 0 Gadgets.
DC.L 0 Grafisch.
DC.L WindowTitel
DC.L 0 Screen (0=WorkBench).(30)
DC.L 0 bitmap (geen). (34)
DC.W 0,0 Breedte/Hoogte minimaal.
DC.W 0,0 Breedte/Hoogte maximaal.
DC.W 1 Scherm-type : 1=WorkBench, 15=custom
xOffs equ 10
brd equ 160
hgt equ 12
yOffs equ xOffs+brd+10
numgads equ 5
xPapID equ 1
xEenhID equ 2
xInstID equ 3
OkID equ 4
yPapID equ 5
yEenhID equ 6
yInstID equ 7
CancID equ 8
gt_MXList dc.l _log
dc.l _antilog
dc.l _lincm
dc.l _linhalf
dc.l _linmm
dc.l 0
xEenheden dc.l 10
yEenheden dc.l 10
***
*** Maak Gadgets
***
MaakGetTypeGadgets
lea gt_newgad(pc),a1
move.l vis_info(a4),gng_VisualInfo(a1)
clr gng_GadgetID(a1)
moveq #xOffs,d2
move.b xType(pc),d3
lea _xrichting(PC),a0
move.l xEenheden(PC),d0
lea _ok(pc),a3
bsr.b mg_kolomgads
beq.s .end
lea gt_newgad(pc),a1
move #yOffs,d2
move.b yType(pc),d3
lea _yrichting(PC),a0
move.l yEenheden(PC),d0
lea _cancel(pc),a3
bsr.b mg_kolomgads
.end rts
mg_kolomgads
* gadget 1 : Text-gadget : x/y-kolom *
push.l d0
move d2,gng_LeftEdge(a1)
move.l a0,gng_GadgetText(a1)
move #14,gng_TopEdge(a1)
moveq #PLACETEXT_IN,d0
move.l d0,gng_Flags(a1)
move.l gadcont(a4),a0
moveq #TEXT_KIND,d0
sub.l a2,a2
Lib CreateGadgetA
move.l d0,gadcont(a4)
beq.w mg_nogadgets
* gadget 2 : MX-gadget : x/y-papiersoort *
lea gt_newgad(pc),a1
add #hgt,gng_TopEdge(a1)
clr.l gng_GadgetText(a1)
addq #1,gng_GadgetID(a1)
moveq #PLACETEXT_RIGHT,d0
move.l d0,gng_Flags(a1)
move.l gadcont(a4),a0
moveq #MX_KIND,d0
clr.l -(sp)
moveq #0,d1
move.b d3,d1
subq #1,d1
push.l d1
push.l #GTMX_Active
pea 2.w
push.l #GTMX_Spacing
pea gt_MXList(PC)
push.l #GTMX_Labels
MOVE.l SP,a2 taglist
Lib CreateGadgetA
lea 3*8+4(sp),sp
move.l d0,gadcont(a4)
beq.w mg_nogadgets
* gadget 3 : integer-gadget: x/y-eenheden *
lea gt_newgad(PC),a1
add #5*10+INTERHEIGHT,gng_TopEdge(a1)
moveq #80,d0
add d2,d0
move d0,gng_LeftEdge(a1)
move #brd-80,gng_Width(a1)
addq.w #1,gng_GadgetID(a1)
lea _eenheden(PC),a0
move.l a0,gng_GadgetText(a1)
moveq #PLACETEXT_LEFT,d0
move.l d0,gng_Flags(a1)
move.l gadcont(a4),a0
moveq #INTEGER_KIND,d0
move.l (SP),d1
clr.l -(sp) tag_end
pea 4.w
push.l #GTIN_MaxChars
push.l d1 Eenheden-waarde
push.l #GTIN_Number
move.l SP,a2 taglist
Lib CreateGadgetA
lea 5*4(SP),sp
move.l d0,gadcont(a4)
beq.b mg_nogadgets
* gadget 4 : button : x/y-instellingen *
lea gt_newgad(PC),a1
add #hgt+INTERHEIGHT,gng_TopEdge(a1)
move d2,gng_LeftEdge(a1)
move #brd,gng_Width(a1)
addq #1,gng_GadgetID(a1)
lea _instellingen(PC),a0
move.l a0,gng_GadgetText(a1)
moveq #PLACETEXT_IN,d0
move.l d0,gng_Flags(a1)
move.l gadcont(a4),a0
moveq #BUTTON_KIND,d0
sub.l a2,a2 taglist
Lib CreateGadgetA
move.l d0,gadcont(a4)
beq.b mg_nogadgets
* gadget 5 : button : Printen/afbreken *
lea gt_newgad(PC),a1
add #hgt+INTERHEIGHT,gng_TopEdge(a1)
addq #1,gng_GadgetID(a1)
move.l a3,gng_GadgetText(a1)
moveq #PLACETEXT_IN,d0
move.l d0,gng_Flags(a1)
move.l gadcont(a4),a0
moveq #BUTTON_KIND,d0
sub.l a2,a2 taglist
Lib CreateGadgetA
move.l d0,gadcont(a4)
; beq mg_nogadgets
mg_nogadgets
addq #4,sp
rts
** newgadget **
gt_newgad
dc.w 0,0 x/y
dc.w brd,hgt brd/hgt
dc.l 0 text
dc.l topaz8 textattr
dc.w 0 ID
dc.l 0 flags
dc.l 0 vis_info
dc.l 0 userdata
**
** VARIABELEN
**
_decade dc.b 'Breedte van decades',0
_mm dc.b 'mm',0
_pixels dc.b 'pixels',0
_prim dc.b 'Dikte hoofdlijnen',0
_sec dc.b 'Dikte bijlijnen',0
_ter dc.b 'Dikte mm-lijnen',0
_printen dc.b 'Printen',0
_afbreken dc.b 'afbreken',0
_ok dc.b 'Print',0
_goed dc.b 'Ok',0
_cancel dc.b 'Cancel',0
_instellingen dc.b 'Instellingen',0
_eenheden dc.b 'Eenheden',0
_dikte dc.b 'Dikte',0
_diktehalf dc.b 'Dikte halve cm',0
_diktemm dc.b 'Dikte mm',0
_seclog dc.b 'Dikte overige',0
_log dc.b 'logaritmisch',0
_lincm dc.b 'lineair (1 cm)',0
_linhalf dc.b 'lineair (½ cm)',0
_linmm dc.b 'lineair (1 mm)',0
_antilog dc.b 'anti-logaritmisch',0
_xrichting dc.b 'X-richting :',0
_yrichting dc.b 'Y-richting :',0
WindowTitel dc.b 'GraphPaperPrint V1.1 by MVW © 1997',0
xWinNaam dc.b 'X Instellingen',0
yWinNaam dc.b 'Y Instellingen',0
topaznaam dc.b 'topaz.font',0
bodytext dc.b "Can't get",0
_retry dc.b 'Retry',0
even
***** zoek de hoogste waarde in een lijnenarray
***** in : a0 = array
***** uit : d0.w = max
GetMax
move (a0)+,d1 aantal elementen
move (a0)+,d0 eerste max.
subq #2,d1
.lus cmp (a0)+,d0
dblo d1,.lus verder indien d0 >= (a0)
bhs.s .ok
move -2(a0),d0
dbf d1,.lus
.ok rts
***** zoek de laagste waarde in een lijnenarray
***** in : a0 = array
***** uit : d0.w = min
GetMin
move (a0)+,d1 aantal elementen
move (a0)+,d0 eerste min.
subq #2,d1
.lus cmp (a0)+,d0
dbhi d1,.lus verder indien d0 =< (a0)
bls.s .ok
move -2(a0),d0
dbf d1,.lus
.ok rts
***** free lijnenarray
***** in : a0 = array
FreeArray
move.l a0,a1
moveq #0,d0
move (a0),d0 aantal lijnen
add.l d0,d0
addq.l #2,d0 aantal bytes
move.l 4.w,a6
LibJ FreeMem
if debug
****** a5 = ptr naar Array
****** scratch a0/a1/d0-d4
PrintArray
moveq #0,d0
move (a5)+,d4
subq #1,d4
.xpr move (a5)+,d0
bsr pdec
lea _TAB(PC),a0
bsr print
dbf d4,.xpr
lea _LF(PC),a0
bsr print
rts
endif
***** calc-papiersoort
***** in : d0 = aantal eenheden
***** d1 = dpi
***** d2 = breedte primaire lijnen
***** d3 = evt.breedte secundaire lijnen
***** d4 = evt.breedte tertiaire lijnen
***** uit : d0 = ptr naar lijnen-array
***** lijnenarray : eerste woord = aantal lijnen
***** volgende woorden = posities van de lijnen
***** calc-halve-centimeter
***** bereken lijnen met een afstand van 1 cm
***** in : d0.w = aantal eenheden
***** d1.w = dpi
***** d2.l = breedte primaire lijnen (1 cm)
***** d3.l = breedte secundaire lijnen (½ cm)
***** d4.l = breedte tertiaire lijnen (1 mm)
***** uit : d0 = ptr naar lijnen-array
MMREG REG d0-d7/a2/a3
CalcMM ext.l d1
movem.l MMREG,-(SP)
move d0,d5
addq #1,d0
mulu d2,d0 d0 = aantal hoofdlijnen
mulu d5,d3 d3 = aantal bijlijnen
mulu d5,d4
asl.l #3,d4 d4 = aantal mm-lijnen (8 x eenheden x breedte)
add.l d3,d0
add.l d4,d0 d0 = aantal lijnen
move d0,d4 d4=d0
add.l d0,d0
addq.l #2,d0 lengte
moveq #0,d1 eisen = geen
move.l 4.w,a6
lib AllocMem
push.l d0
beq.w .nomem
move.l d0,a2
move d4,(a2)+ sla aantal lijnen op
** bereken offsets
move.l 12(SP),d0 d0 = breedte prim
subq #1,d0 (breedte - 1)
move.l Math(a4),a6
lib Flt
move.l #half,d1 (breedte - 1)/2
lib Mul
move.l d0,a3 a3 = prim. offset
move.l 16(SP),d0 d0 = breedte sec
subq #1,d0
lib Flt
move.l #half,d1
lib Mul (breedte - 1)/2
move.l d0,d5 d5 = sec. offset
move.l 20(SP),d0 d0 = breedte ter
subq #1,d0
Lib Flt
move.l #half,d1
Lib Mul (breedte - 1)/2
move.l d0,d6 d6 = ter. offset
** kijk welke offset het grootste is; de grootste offset = begin-offset
move.l a3,d1 prim.offset
lib Cmp sign( d1 - d0 )
tst.l d0
bmi.s .ter
move.l a3,d3 start-offset = prim. offset
bra.s .prim
.ter move.l d6,d3 start-offset = ter. offset
.prim move.l d5,d1
move.l d3,d0
Lib Cmp sign( d1 - d0 )
tst.l d0
bmi.s .ok -> start-offset = prim. of sec. offset
move.l d5,d3 start-offset = sec. offset
.ok move.l d3,d0
move.l #half,d1
lib Add
move.l d0,d3 start-offset met afronding
move.l a3,d0
lib Neg inverteer prim.offset
move.l d0,a3
move.l d5,d0
lib Neg inverteer sec. offset
move.l d0,d5
move.l d6,d0
lib Neg inverteer ter. offset
move.l d0,d6
** bereken het aantal punten per mm
move.l 8(SP),d0 dpi.l
move.l Math(a4),a6
lib Flt
move.l #cmpinch,d1
Lib Mul
move.l #tiende,d1 d0 = punten per cm
Lib Mul
move.l d0,d7 d7 = dots per mm
** vul de lijst in
move.l 4(SP),d2
subq #1,d2 aantal eenheden -1
.lus * prim.lijn
move.l d3,d0 beginwaarde
move.l a3,d1 prim.offset
lib Add
lib Fix
move.l 12(SP),d1 breedte prim.lijn
subq #1,d1
.1 move d0,(a2)+
addq #1,d0
dbf d1,.1
bsr.b mmlines teken 4 millemeter-lijntjes
move.l d3,d0
move.l d7,d1
Lib Add verhoog waarde met een mm
move.l d0,d3
* sec.lijn
move.l d5,d1 sec. offset
Lib Add
Lib Fix
move.l 16(SP),d1 breedte sec.lijn
subq #1,d1
.2 move d0,(a2)+
addq #1,d0
dbf d1,.2
bsr.b mmlines teken 4 millimeter-lijntjes
move.l d3,d0
move.l d7,d1
Lib Add verhoog waarde met een mm
move.l d0,d3
dbf d2,.lus volgende cm
** laatste prim.lijn
move.l a3,d1 prim.offset
lib Add
lib Fix
move.l 12(SP),d1 breedte prim.lijn
subq #1,d1
.3 move d0,(a2)+
addq #1,d0
dbf d1,.3
.canmem
pop.l a0
movem.l (SP)+,MMREG
move.l a0,d0
rts
.nomem lea _mem(PC),a0
lea .retmem(PC),a1
lea .canmem(PC),a2
bra.w AutoReq
.retmem addq.l #4,SP
movem.l (SP)+,MMREG
bra.w CalcMM
***** 4x ter.lijn
mmlines moveq #3,d4
.1 move.l d3,d0
move.l d7,d1 een mm
Lib Add verhoog waarde met een mm
move.l d0,d3
move.l d6,d1 ter. offset
Lib Add
Lib Fix
move.l 20(SP),d1 breedte ter.lijn
subq #1,d1
.2 move d0,(a2)+
addq #1,d0
dbf d1,.2
dbf d4,.1
rts
***** calc-halve-centimeter
***** bereken lijnen met een afstand van 1 cm
***** in : d0.w = aantal eenheden
***** d1.w = dpi
***** d2.l = breedte primaire lijnen
***** d3.l = breedte secundaire lijnen
***** uit : d0 = ptr naar lijnen-array
HALFREG REG d0-d6/a2
CalcHalf
ext.l d1
movem.l HALFREG,-(SP)
move d0,d4
addq #1,d0
mulu d2,d0 d0 = aantal hoofdlijnen
mulu d3,d4 d4 = aantal bijlijnen
add.l d4,d0 d0 = totaal aantal lijnen
move d0,d4 d4=d0
add.l d0,d0
addq.l #2,d0 lengte
moveq #0,d1 eisen = geen
move.l 4.w,a6
lib AllocMem
push.l d0
beq.w .nomem
move.l d0,a2
move d4,(a2)+ sla aantal lijnen op
** bereken offsets
move.l 12(SP),d0 d0 = breedte prim
subq #1,d0 (breedte - 1)
move.l Math(a4),a6
lib Flt
move.l #half,d1 (breedte - 1)/2
lib Mul
move.l d0,d4 d4 = prim. offset
move.l 16(SP),d0 d0 = breedte sec
subq #1,d0
lib Flt
move.l #half,d1
lib Mul (breedte - 1)/2
move.l d0,d5 d5 = sec. offset
move.l d4,d1 prim.offset
** kijk welke offset het grootste is; de grootste offset = begin-offset
lib Cmp sign( d1 - d0 )
tst.l d0
bmi.s .sec
move.l d4,d3 start-offset = prim. offset
bra.s .prim
.sec move.l d5,d3 start-offset = sec. offset
.prim move.l d3,d0
move.l #half,d1
lib Add
move.l d0,d3 start-offset met afronding
move.l d4,d0
lib Neg inverteer prim.offset
move.l d0,d4
move.l d5,d0
lib Neg inverteer sec. offset
move.l d0,d5
** bereken het aantal punten per halve cm
move.l 8(SP),d0 dpi.l
move.l Math(a4),a6
lib Flt
move.l #cmpinch,d1
Lib Mul
move.l #half,d1 d0 = punten per cm
Lib Mul
move.l d0,d6 d6 = dots per halve cm
** vul de lijst in
move.l 4(SP),d2
subq #1,d2 aantal eenheden -1
.lus * prim.lijn
move.l d3,d0 beginwaarde
move.l d4,d1 prim.offset
lib Add
lib Fix
move.l 12(SP),d1 breedte prim.lijn
subq #1,d1
.1 move d0,(a2)+
addq #1,d0
dbf d1,.1
move.l d3,d0
move.l d6,d1
Lib Add verhoog waarde met een halve cm
move.l d0,d3
* sec.lijn
move.l d5,d1 sec. offset
Lib Add
Lib Fix
move.l 16(SP),d1 breedte sec.lijn
subq #1,d1
.2 move d0,(a2)+
addq #1,d0
dbf d1,.2
move.l d3,d0
move.l d6,d1
Lib Add verhoog waarde met een halve cm
move.l d0,d3
dbf d2,.lus volgende cm
** laatste prim.lijn
move.l d4,d1 prim.offset
lib Add
lib Fix
move.l 12(SP),d1 breedte prim.lijn
subq #1,d1
.3 move d0,(a2)+
addq #1,d0
dbf d1,.3
.nomem
pop.l a0
movem.l (SP)+,HALFREG
move.l a0,d0
rts
***** calc-centimeter
***** bereken lijnen met een afstand van 1 cm
***** in : d0.w = aantal eenheden
***** d1.w = dpi
***** d2.l = breedte primaire lijnen
***** uit : d0 = ptr naar lijnen-array
CENTREG REG d0-d4/a2
CalcCent
ext.l d1
movem.l CENTREG,-(SP)
addq #1,d0
mulu d2,d0 d0 = aantal lijnen
move d0,d3
add.l d0,d0
addq.l #2,d0 lengte
moveq #0,d1 eisen
move.l 4.w,a6
lib AllocMem
push.l d0
beq.b .nomem
move.l d0,a2
move d3,(a2)+ sla aantal lijnen op
move.l 8(SP),d0 dpi.l
move.l Math(a4),a6
lib Flt
move.l #cmpinch,d1
Lib Mul
move.l d0,d4 d4 = dots per cm
move.l 4(SP),d2 aantal hokjes
move.l #half,d0 d0 = beginwaarde = 0(int)
.lus move.l d0,d3
Lib Fix afronden
move.l 12(SP),d1 dikte van de lijn
subq #1,d1
.lijn move d0,(a2)+ xpos++
addq #1,d0
dbf d1,.lijn
move.l d3,d0
move.l d4,d1
Lib Add
dbf d2,.lus
.nomem
pop.l a0
movem.l (SP)+,CENTREG
move.l a0,d0
rts
***** calc-log
***** in : d0.w = aantal eenheden = aantal decaden
***** d1.l = breedte van eenheid in mm
***** d2.w = dpi
***** d3.w = breedte primaire lijnen = begin van decade
***** d4.w = breedte secundaire lijnen = overige lijnen
***** uit : d0 = ptr naar lijnen-array
LOGREG REG d0-d6/a2/a3
CalcLog ext.l d2
movem.l LOGREG,-(SP)
addq #1,d0
mulu d0,d3 aantal hoofdlijnen x breedte
subq #1,d0
mulu d4,d0 aantal decades x breedte bijlijn
asl.l #3,d0 x aantal bijlijnen per decade (8)
add.l d3,d0 d0 = aantal lijnen
move d0,d3
add.l d0,d0
addq.l #2,d0 lengte
moveq #0,d1 eisen
move.l 4.w,a6
lib AllocMem
push.l d0
beq.w .nomem
move.l d0,a2
move d3,(a2)+ aantal lijnen opslaan
** bereken offsets
move.l 16(SP),d0
subq #1,d0 (breedte - 1)
move.l Math(a4),a6
lib Flt
move.l #half,d1 (breedte - 1)/2
lib Mul
move.l d0,d4 prim. offset
move.l 20(SP),d0
subq #1,d0
lib Flt
move.l #half,d1
lib Mul (breedte - 1)/2
move.l d0,d5 sec. offset
move.l d4,d1 prim.offset
lib Cmp sign( d1 - d0 )
tst.l d0
bmi.s .sec
move.l d4,d3 start-offset
bra.s .prim
.sec move.l d5,d3
.prim move.l d3,d0
move.l #half,d1
lib Add
move.l d0,d3 start-offset met afronding
move.l d4,d0
lib Neg inverteer prim.offset
move.l d0,d4
move.l d5,d0
lib Neg inverteer sec. offset
move.l d0,d5
** bereken het aantal punten per decade
move.l 8(SP),d0 lengte in mm (d1.l)
lib Flt
move.l d0,d2
move.l 12(SP),d0 dpi.l
lib Flt
move.l #cmpinch,d1
Lib Mul d0 = #dots per cm
move.l d2,d1
Lib Mul #dots per tien decades
move.l #tiende,d1
Lib Mul d6 = #dots per decade
move.l d0,d6
** vul de lijst in
move.l 4(SP),d2
subq #1,d2 aantal eenheden -1
.primlus * prim.lijn
move.l d3,d0 beginwaarde
move.l d4,d1 prim.offset
lib Add
lib Fix
move.l 16(SP),d1 breedte prim.lijn
subq #1,d1
.1 move d0,(a2)+
addq #1,d0
dbf d1,.1
push.w d2
moveq #8-1,d2
lea logtab+4(pc),a3
.seclus * secundaire lijnen
move.l d6,d0
move.l (a3)+,d1
lib Mul
move.l d3,d1 offset
lib Add
move.l d5,d1 sec.offset
lib Add
lib Fix
move.l 22(SP),d1 breedte sec.lijn
subq #1,d1
.2 move d0,(a2)+
addq #1,d0
dbf d1,.2
dbf d2,.seclus
pop.w d2
move.l d6,d0
move.l d3,d1
lib Add verhoog offset
move.l d0,d3
dbf d2,.primlus
** laatste prim.lijn
move.l d4,d1 prim.offset
lib Add
lib Fix
move.l 16(SP),d1 breedte prim.lijn
subq #1,d1
.3 move d0,(a2)+
addq #1,d0
dbf d1,.3
.nomem pop.l a0
movem.l (SP)+,LOGREG
move.l a0,d0
rts
********
******** maak de structuren om te tekenen
********
InitGFX moveq #rp_SIZEOF,D0
MOVE.l #MEMF_PUBLIC!MEMF_CLEAR,D1
move.l 4.w,a6
Lib AllocMem geheugen voor rastport
move.l d0,rport2(a4)
beq.w norport
moveq #bm_SIZEOF,D0
MOVE.l #MEMF_PUBLIC!MEMF_CLEAR,D1
Lib AllocMem geheugen voor bitmap
move.l d0,bmap2(a4)
beq.w nobmap
move.l gfxbase(a4),a6
move.l d0,a0
moveq #1,d0 1 bitplane
moveq #0,d1
move Width(a4),d1
moveq #0,d2
move Height(a4),d2
Lib InitBitMap init bitmap
moveq #0,d0
move Width(a4),d0
moveq #0,d1
move Height(a4),d1
Lib AllocRaster alloc plane1
move.l bmap2(a4),a0
move.l d0,bm_Planes(a0)
beq.b noraster
move.l rport2(a4),a1
Lib InitRastPort
move.l rport2(a4),a1 zet de bitmap in rastport
move.l bmap2(a4),rp_BitMap(a1)
moveq #1,d0
move.l rport2(a4),a1
Lib SetAPen
moveq #2,d0
Lib GetColorMap
move.l d0,cmap2(a4)
beq.b nocolor
move.l d0,a0
push.l d0
moveq #0,d0
moveq #15,d1
moveq #15,d2
moveq #15,d3
Lib SetRGB4CM zet kleur 0 = wit
pop.l a0
moveq #1,d0
moveq #0,d1
moveq #0,d2
moveq #0,d3
Lib SetRGB4CM zet kleur 1 = zwart
rts
*****
***** ruim alle teken-structuren op
*****
wisstruct
move.l cmap2(a4),a0
move.l gfxbase(a4),a6
Lib FreeColorMap
nocolor
move.l bmap2(a4),a0
move.l bm_Planes(a0),a0
moveq #0,d0
move Width(a4),d0
moveq #0,d1
move Height(a4),d1
move.l gfxbase(a4),a6
Lib FreeRaster
noraster
move.l bmap2(a4),a1
moveq #bm_SIZEOF,D0
move.l 4.w,a6
Lib FreeMem
nobmap
move.l rport2(a4),a1
moveq #rp_SIZEOF,D0
Lib FreeMem
norport
moveq #-1,d0
rts
********
******** Open de printer en init variabelen als PD, PED etc.
********
InitPrinter
sub.l a1,a1
move.l 4.w,a6
Lib FindTask onze task zoeken
lea wrep(a4),a1
move.l d0,$10(a1)
Lib AddPort reply-port toevoegen
moveq #-1,d0
Lib AllocSignal
move.b d0,wrep+MP_SIGBIT(a4) zet sigbit
move.l Signals(a4),d1
bset d0,d1
move.l d1,Signals(a4) zet bit in signals
lea PrtIO(a4),a1
lea wrep(a4),a0
move.l a0,14(a1) reply-port
moveq #0,d0 device 0
moveq #0,d1 geen vlaggen
lea printer(PC),a0
Lib OpenDevice printer.dev openen
tst.l d0
bne.b .noprt Openingsfout -> exit
lea PrtIO(a4),a0
move.l IO_DEVICE(a0),PD(a4)
move.l PD(a4),a1
move.l pd_SegmentData(a1),a1
lea ps_PED(a1),a1
move.l a1,PED(a4)
move ped_NumRows(a1),Height(a4) hoogte vd. rastport
move.l PD(a4),a1 stel prefs in
lea pd_Preferences(a1),a1
move #IMAGE_POSITIVE,pf_PrintImage(a1) positief
move #ASPECT_HORIZ,pf_PrintAspect(a1) horizontaal
move #SHADE_BW,pf_PrintShade(a1) zwart/wit
rts
.noprt bsr.w remprt verwijder reply-port
moveq #1,d0 foutcode
rts
******
****** Dump de rastport
******
** in : d0.w = hoogte
** uit : d0.b = errorcode
DumpDeel
lea PrtIO(a4),a1
move #PRD_DUMPRPORT,IO_COMMAND(a1) commando (dump scherm)
lea 32(a1),a0
move.l rport2(a4),(a0)+ ; 32 rastport
move.l cmap2(a4),(a0)+ ; 36 colormap
clr.l (a0)+ ; 40 (viewport)modes (geen)
clr.l (a0)+ ; 44 scrX,scrY
move Width(a4),d1
move d1,(a0)+ ; 48 breedte
move d0,(a0)+ ; 50 hoogte
ext.l d1
ext.l d0
move.l d1,(a0)+ ; 52 io_DestCols
move.l d0,(a0)+ ; 56 io_DestRows
move #SPECIAL_NOFORMFEED,io_Special(a1) ; geen special
move.l 4.w,a6
Lib SendIO ; print rastport
.wait move.l Signals(a4),d0
move.l 4.w,a6
Lib Wait
move.b wrep+MP_SIGBIT(A4),D1
btst d1,d0
bne.s .prtio
move.l WindowHD(a4),a0
move.l wd_UserPort(a0),a0
move.b MP_SIGBIT(A0),D1
btst d1,d0
bne.s .aborted
.prtio lea wrep(a4),a0
Lib GetMsg
tst.l d0
beq.s .wait
lea PrtIO(a4),a1
move.b IO_ERROR(a1),d0
rts
.aborted * afgebroken of refresh *
move.l gadbase(a4),a6
Lib GT_GetIMsg
move.l d0,a1
tst.l d0
beq.b .wait geen msg
move.l im_Class(a1),d2 IDCMP-code
Lib GT_ReplyIMsg
cmp.l #IDCMP_REFRESHWINDOW,d2
beq.b .refrwin
* afgebroken *
lea PrtIO(a4),a1
move.l 4.w,a6
Lib AbortIO
move.b #PDERR_CANCEL,d0 ge'cancel'd
rts
.refrwin * refresh window *
move.l WindowHD(a4),a0
Lib GT_BeginRefresh
move.l WindowHD(a4),a0
moveq #1,d0
Lib GT_EndRefresh
bra.b .wait
******
****** sluit de printer
******
ClosePrt
lea PrtIO(a4),a1
move.l 4.w,a6
Lib CloseDevice sluit printer
remprt
moveq #0,d0
move.b wrep+MP_SIGBIT(A4),D0
move.l 4.w,a6
Lib FreeSignal
lea wrep(a4),a1
Lib RemPort verwijder poort
rts
hokx = 10 ; tien hokjes breed
hoky = 7 ; 7 hokjes hoog
linlin = 0 print dubbel-lineair ?
loglog = 1 print dubbel-logaritmisch ?
***
*** Maak Gadgets
***
MaakAbortGadgets
* gadget 1 : button: afbreken *
lea ab_newgad(PC),a1
move.l vis_info(a4),gng_VisualInfo(a1)
move.l gadcont(a4),a0
moveq #BUTTON_KIND,d0
sub.l a2,a2 taglist
Lib CreateGadgetA
move.l d0,gadcont(a4)
rts
** newgadget **
ab_newgad
dc.w 10,15 x/y
dc.w AbortX,AbortY brd/hgt
dc.l _afbreken text
dc.l topaz9 textattr
dc.w 0 ID
dc.l PLACETEXT_IN flags
dc.l 0 vis_info
dc.l 0 userdata
*******
******* Het hoofdprogramma
*******
main bsr.w GetType
tst d0
beq.s .end
.retaw lea AbortWin(PC),a0
bsr.w opengtwin
tst.l d0
beq.b .nowin geen window !! ->
bsr.b MaakAbortGadgets
tst.l d0
beq.b .noabgadgets
* gadgets toevoegen aan window *
bsr.w addgtgads
* print pagina *
move.l WindowHD(a4),a0
moveq #0,d0
move.l wd_UserPort(a0),a0
move.b MP_SIGBIT(A0),D1
bset d1,d0
move.l d0,Signals(a4)
bsr.s printpaper
.noabgadgets
move.l WindowHD(a4),a0
move.l 4(a0),AbortWin
bsr.w CloseWin
bra.b main
.end rts
.nowin lea _window(PC),a0
lea .retaw(PC),a1
lea .end(PC),a2
bra.w AutoReq
printpaper
bsr.w InitPrinter installeer de printer
tst.b d0
bne.b .noprt
.retmem1
moveq #0,d0
move.b xType(pc),d0
add d0,d0
add .xpaptab-2(PC,d0.w),d0
jsr .xpaptab-2(PC,d0.w)
tst.l d0
beq.b .nomem1
move.l d0,a2 a2 = array met x-pos
.retmem2
moveq #0,d0
move.b yType(pc),d0
add d0,d0
add .ypaptab-2(PC,d0.w),d0
jsr .ypaptab-2(PC,d0.w)
tst.l d0
beq.b .nomem2
move.l d0,a3 a3 = array met y-pos
bra.s .print
.xpaptab
dr.w xLogPapier
dr.w xALogPapier
dr.w xLincmPapier
dr.w xLinhalfPapier
dr.w xLinmmPapier
.ypaptab
dr.w yLogPapier
dr.w yALogPapier
dr.w yLincmPapier
dr.w yLinhalfPapier
dr.w yLinmmPapier
.print
if debug
lea _xpos(PC),a0
bsr print
move.l a2,a5
bsr PrintArray
lea _ypos(PC),a0
bsr print
move.l a3,a5
bsr PrintArray
endif
move.l a2,a0
bsr.w GetMax
addq #1,d0
move d0,Width(a4)
.retGFX bsr.w InitGFX maak teken-structuren
tst d0
bne.b .nogfx
bsr.w PrintLijnen print de tekening
bsr.w wisstruct verwijder teken-structuren
.GFXcan
move.l a3,a0
bsr.w FreeArray geef lijnenarray vrij
.canmem2
move.l a2,a0
bsr.w FreeArray geef lijnenarray vrij
.canmem1
bsr.w ClosePrt sluit de printer
.ex rts
.noprt
lea printer(PC),a0 tekst
lea printpaper(PC),a1 retry
lea .ex(PC),a2 cancel
bra.w AutoReq
.nomem1
lea _mem(PC),a0
lea .retmem1(PC),a1
lea .canmem1(PC),a2
bra.w AutoReq
.nomem2
lea _mem(PC),a0
lea .retmem2(PC),a1
lea .canmem2(PC),a2
bra.w AutoReq
.nogfx
lea _noGFXMem(PC),a0
lea .retGFX(PC),a1
lea .GFXcan(PC),a2
bra.w AutoReq
* log in x-richting
xLogPapier
move.l xEenheden(PC),d0 #decaden
move.l xDecbrd(pc),d1 aantal mm per decade
move.l PED(a4),a1
move ped_XDotsInch(a1),d2 xdpi
move.l xPrimdkt(pc),d3 prim.dikte
move.l xSecdkt(pc),d4 sec. dikte
bsr.w CalcLog
rts
* log in y-richting
yLogPapier
move.l yEenheden(PC),d0 #decaden
move.l yDecbrd(pc),d1 aantal mm per decade
move.l PED(a4),a1
move ped_YDotsInch(a1),d2 ydpi
move.l yPrimdkt(pc),d3 prim.dikte
move.l ySecdkt(pc),d4 sec. dikte
bsr.w CalcLog
rts
* Antilog in x-richting
xALogPapier
bsr.b xLogPapier
tst.l d0
beq.b .nomem
push.l d0
move.l d0,a0
bsr.w GetMax
move.l (SP),a0
move (a0)+,d1
subq #1,d1
.1 move d0,d2 d0 = max
sub (a0),d2
move d2,(a0)+ (a0) = max - (a0)
dbf d1,.1
pop.l d0
.nomem rts
* Antilog in y-richting
yALogPapier
bsr.b yLogPapier
tst.l d0
beq.b .nomem
push.l d0
move.l d0,a0
bsr.w GetMax
move.l (SP),a0
move (a0)+,d1
subq #1,d1
.1 move d0,d2 d0 = max
sub (a0),d2
move d2,(a0)+ (a0) = max - (a0)
dbf d1,.1
pop.l d0
.nomem rts
* lin cm in x-richting
xLincmPapier
move.l xEenheden(PC),d0
move.l PED(a4),a1
move ped_XDotsInch(a1),d1 xdpi
move.l xPrimdkt(pc),d2 breedte van de lijnen
bsr.w CalcCent
rts
* lin cm in y-richting
yLincmPapier
move.l yEenheden(PC),d0
move.l PED(a4),a1
move ped_YDotsInch(a1),d1 ydpi
move.l yPrimdkt(pc),d2 breedte van de lijnen
bsr.w CalcCent
rts
* lin halve cm in x-richting
xLinhalfPapier
move.l xEenheden(PC),d0
move.l PED(a4),a1
move ped_XDotsInch(a1),d1 xdpi
move.l xPrimdkt(pc),d2 breedte van de lijnen
move.l xSecdkt(PC),d3
bsr.w CalcHalf
rts
* lin halve cm in y-richting
yLinhalfPapier
move.l yEenheden(PC),d0
move.l PED(a4),a1
move ped_YDotsInch(a1),d1 ydpi
move.l yPrimdkt(pc),d2 breedte van de lijnen
move.l ySecdkt(PC),d3
bsr.w CalcHalf
rts
* lin mm in x-richting
xLinmmPapier
move.l xEenheden(PC),d0
move.l PED(a4),a1
move ped_XDotsInch(a1),d1 xdpi
move.l xPrimdkt(pc),d2 breedte van de lijnen
move.l xSecdkt(PC),d3
move.l xTerdkt(PC),d4
bsr.w CalcMM
rts
* lin mm in y-richting
yLinmmPapier
move.l yEenheden(PC),d0
move.l PED(a4),a1
move ped_YDotsInch(a1),d1 ydpi
move.l yPrimdkt(pc),d2 breedte van de lijnen
move.l ySecdkt(PC),d3
move.l yTerdkt(PC),d4
bsr.w CalcMM
rts
*******
******* Print de lijnen zoals aangegeven in de twee lijnenarrays
******* in : a2 = (xpos) verticale lijnen-array
******* a3 = (ypos) horizontale lijnen-array
*******
PRINTREG REG D2-D4/A2/A3
PrintLijnen
movem.l PRINTREG,-(SP)
move.l a3,a0
bsr.w GetMax
move d0,d4 max.y
.volg move d4,d3 d4 = hoogste waarde te printen
sub Height(a4),d3 - hoogte
addq #1,d3 d3 = laagste waarde te printen
moveq #0,d0
move.l rport2(a4),a1
move.l gfxbase(a4),a6
Lib SetRast maak veld schoon
move.l a2,a0
bsr.b DrawVert teken lijnen
move.l a3,a0
bsr.b DrawHoriz
move Height(a4),d0 standaard hoogte
cmp d0,d4
bcc.s .1
move d4,d0 laatste regel is korter
.1 bsr.w DumpDeel print regel
tst.b d0
bne.b .perror
sub Height(a4),d4
bcc.b .volg volgende regel
.perror movem.l (SP)+,PRINTREG
RTS
DrawVert
push.l a2
move.l a0,a2
move (a2)+,d2
subq #1,d2
.lus moveq #0,d0
move (a2),d0 xpos
moveq #0,d1 ypos
move.l rport2(a4),a1
Lib Move
moveq #0,d0
move (a2)+,d0 xpos
tst d3
bmi.b .spec
moveq #0,d1
move Height(a4),d1
subq #1,d1 ypos
bra.b .ok
.spec moveq #0,d1
move Height(a4),d1 (hoogte-1 )+(d3) (d3 < 0)
subq #1,d1
add d3,d1 ypos
.ok Lib Draw
dbf d2,.lus
pop.l a2
rts
DrawHoriz
push.l a2
move.l a0,a2
move (a2)+,d2
subq #1,d2
.lus moveq #0,d1
move (a2)+,d1 ypos
cmp d4,d1
bgt.b .nodraw (ypos > max) ->
cmp d3,d1
blt.b .nodraw (ypos < min) ->
sub d4,d1
neg d1
moveq #0,d0 xpos
Lib Move
moveq #0,d1
move -2(a2),d1
sub d4,d1
neg d1
moveq #0,d0
move Width(a4),d0
Lib Draw
.nodraw
dbf d2,.lus
pop.l a2
rts
if debug
ConHD dc.l 0
_dec dc.b '0.0000',0
EXP dc.b 0
ConName dc.b 'CON:10/10/510/200/Uitvoer-Window',0
_LF dc.b 10,0
_TAB dc.b 9,0
_TVV dc.b ' < Return voor verder >',0
_BINEXP dc.b 'DEC',0
_SHSH dc.b '+E',0
_Punt dc.b '.',0
_Buff dc.b ' ',0
_Min dc.b '-',0
_NoMath dc.b "Can't open mathffp.library"
_NoMathTR dc.b "Can't open mathtrans.library"
endif
dosnaam DOSNAME
intuition INTNAME
graphics GRAFNAME
iconnaam dc.b 'icon.library',0
MathName dc.b 'mathffp.library',0
MathTRName dc.b 'mathtrans.library',0
gadnaam dc.b 'gadtools.library',0
_window dc.b 'window',0
_mem dc.b 'memory',0
_noGFXMem dc.b 'GFX-memory',0
printer dc.b 'printer.device',0
_xpos dc.b 'X-posities :',10,0
_ypos dc.b 'Y-posities :',10,0
_ld dc.b '%ld',0
even
logtab dc.l $0 log(1)=0
dc.l $9a209b3f log(2)
dc.l $f4493d3f log(3)
dc.l $9a209b40 log(4)=2*log(2)
dc.l $b2efb240
dc.l $c734ec40
dc.l $d8585740
dc.l $e730e840
dc.l $f4493d40 log(9)=2*log(3)
dc.l $80000041 log(10)=1
* instellingen
xDecbrd dc.l 25 breedte van een decade in mm
xPrimdkt dc.l 2 dikte hoofdlijnen in pixels
xSecdkt dc.l 1 " bij- " "
xTerdkt dc.l 1 " mm- " "
yDecbrd dc.l 25
yPrimdkt dc.l 3
ySecdkt dc.l 1
yTerdkt dc.l 1
xType dc.b 1
yType dc.b 1
;======= Variabelen
rsreset
DosBase rs.l 1
intbase rs.l 1
gfxbase rs.l 1
gadbase rs.l 1
WindowHD rs.l 1
vis_info rs.l 1 visual-info
gadlist rs.l 1 eerste gadget
gadcont rs.l 1 gadtools-context
Math rs.l 1
MathTR rs.l 1
rport2 rs.l 1
bmap2 rs.l 1
cmap2 rs.l 1
Width rs.w 1
Height rs.w 1
Signals rs.l 1
* printer
PD rs.l 1
PED rs.l 1
wrep rs.b MP_SIZE ; reply-port
PrtIO rs.b 64 ; IO-request-structuur
datasize rs.b 0
end